package com.promonkey.biz.impl;

import com.promonkey.biz.PetBase;

/**
 * Created by promonkey on 2017/2/21.
 */
public class Cat implements PetBase{

    private String name;
    private int age;
    private int health;

    private static Cat cat;

    //因为我只有一只小猫，所以私有化构造器，写成了单例模式
    private Cat(String name, int age, int health) {
        this.name = name;
        this.age = age;
        this.health = health;
    }

    //Mark吃鱼
    public String eat() {
        return this.name + " eat fish!";
    }

    //Mark喜欢玩球类
    public String exercise() {
        return this.name + " paly ball!";
    }

    //Mark抓老鼠
    public String catchMouse(){
        return this.name + " catch mouse!";
    }

    //获得Mark对象
    public static Cat getCat() {
        if (cat == null) {
            cat = new Cat("Mark", 2, 90);
        }
        return cat;
    }

    public String getName() {
        return name;
    }

    public int getAge() {
        return age;
    }

    public int getHealthValue() {
        return health;
    }

    /**
     * 为了方便显示出动物的一些属性值，重写了toString方法
     */
    @Override
    public String toString() {
        return "-------\n" +
                "name:" + this.getName() +
                "\nage:" + this.getAge() +
                "\nhealth:" + this.getHealthValue() +
                "\n-------";
    }
}
